package edu.hunau.cxb19.oop.class31;

/**
 * 懒汉模式:按需加载
 * 
 * @author hb
 *
 *         2020-04-16 15:09:43
 */
public class SingletonLazy {
	private static SingletonLazy instance = null;
	private SingletonLazy() { }

	// 当前静态方法中的同步监视器为:SingletonLazy.class
	public static SingletonLazy newInstance() {
		if (instance == null) {
			synchronized (SingletonLazy.class) {
				if (instance == null) {
					instance = new SingletonLazy();
				}
			}
		}
		return instance;
	}
}
